let layer;
let form;
layui.use(['layer', 'form'], function () {
    layer = layui.layer;
    form = layui.form;
    form.verify({
        length: [
            /^\S{6,12}$/, '密码必须6到12位，且不能出现空格'
        ],
        same: function (value) { //value：表单的值、item：表单的DOM对象

            if (value != $(".newPwd").val()) {
                return "确认密码和新密码不一致！"
            }
        },
        diff: function (value) { //value：表单的值、item：表单的DOM对象
            if (value == $(".oldPwd").val()) {
                return "新密码和原密码不能一致"
            }
        },

    })

    $("form").on("submit", function (e) {
        e.preventDefault();
        // 1.收集数据
        let data = $(this).serialize();
        // 2.发送
        $.ajax({
            url: "/my/updatepwd",
            type: "POST",
            data: data,
            success: function (res) {
                layer.msg(res.message);
            }
        });
    })
})